#! /bin/sh
export JAVA_HOME=/sysnet/tools/jdk1.6.0
export PATH=$JAVA_HOME/bin:$PATH
export JBOSS_HOME=/sysnet/servers/jboss-4.2.3.GA
export OPENEMPI_HOME=/sysnet/projects/openempi-development/openempi
export RUNUSER=odysseas
export HOSTNAME=localhost

. $OPENEMPI_HOME/../openempi_env.sh

## BEGIN INIT INFO
# Provides:          jboss
# Required-Start:    $local_fs $remote_fs $network $syslog 
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start/Stop JBoss AS v4.2.3
### END INIT INFO
#

case "$1" in
    start)
        echo "Starting JBoss AS 4.2.3"
        start-stop-daemon --start --quiet --background --chuid $RUNUSER --exec ${JBOSS_HOME}/bin/run.sh -- -b $HOSTNAME
    ;;
    stop)
        echo "Stopping JBoss AS 4.2.3"
        start-stop-daemon --start --quiet --background --chuid $RUNUSER --exec ${JBOSS_HOME}/bin/shutdown.sh -- --shutdown --server $HOSTNAME
    ;;
    *)
        echo "Usage: /etc/init.d/jboss {start|stop}"
        exit 1
    ;;
esac

exit 0
